package cn.zcj.studytest.controller;


import cn.zcj.studytest.ThrowData.Result;
import cn.zcj.studytest.domain.Message;
import cn.zcj.studytest.service.MessageService;
import cn.zcj.studytest.service.SignUpService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/Message")
@Slf4j
public class MessageController {

    @Resource
    private MessageService messageService;

    @RequestMapping("/getMessage")
    public Result getMessage(@RequestBody Message message){
        Result result = new Result();
        try {
          return  messageService.getMessage(message);
        }catch (Exception e){
            result.setMsg("获取失败");
            result.setSuccess(false);
            return result;
        }
    }

    @RequestMapping("/insertMessage")
    public Result insertMessage(@RequestBody Message message){
        Result result = new Result();
        try {
            return  messageService.insertMessage(message);
        }catch (Exception e){
            result.setMsg("插入失败");
            result.setSuccess(false);
            return result;
        }
    }
}
